﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
#if !WINDOWS_PHONE


#endif

namespace DARE
{
    [AttrTypeDependentSerializable(typeof(DARE.Save.DataStructures.CFirstPersonCameraData))]
    public class CFirstPersonCamera : CCamera
    {

    #region properties

        /// <summary>
        /// Smooth the camera's position.
        /// </summary>
        public bool Smooth
        {
            get { return m_node.SmoothPosition; }
            set { m_node.SmoothPosition = value; }
        }

        /// <summary>
        /// Amount of smooth. See node's smooth definition for more informations.
        /// </summary>
        public float SmoothAmount
        {
            get { return m_node.SmoothPositionAmount; }
            set { m_node.SmoothPositionAmount = value; }
        }

    #endregion

    #region ctor

        /// <summary>
        /// Create the first person camera with a name.
        /// </summary>
        /// <param name="name">Name of the camera.</param>
        public CFirstPersonCamera(string name) :
            base(name)
        { }

    #endregion

    #region methods

        /// <summary>
        /// Set the camera's position relative to the world.
        /// </summary>
        /// <param name="position">Position.</param>
        public void SetPosition(Vector3 position)
        {
            if (AttachedToNode)
                return;
            m_node.SetPosition(position, CNode.ESpace.WORLD);
            m_needUpdateView = true;
        }

        /// <summary>
        /// Translate the camera relative to the world for the Up axis and local for Strafe and Heading.
        /// </summary>
        /// <param name="move">Moves.</param>
        public void Translate(Vector3 move)
        {
            if (AttachedToNode)
                return;
            m_node.Translate(0, move.Y, 0, CNode.ESpace.WORLD);
            m_node.Translate(move.X, 0, move.Z, CNode.ESpace.LOCAL);
            m_needUpdateView = true;
        }

        /// <summary>
        /// Set the camera's orientation.
        /// </summary>
        /// <param name="orientation">Orientation.</param>
        public void SetOrientation(Vector3 orientation)
        {
            if (AttachedToNode)
                return;
            m_node.SetOrientation(orientation.Y, orientation.X, orientation.Z, CNode.ESpace.WORLD);
            m_needUpdateView = true;
        }

        /// <summary>
        /// Set the camera's orientation.
        /// </summary>
        /// <param name="orientation">Orientation.</param>
        public void SetOrientation(Quaternion orientation)
        {
            if (AttachedToNode)
                return;
            m_node.SetOrientation(orientation, CNode.ESpace.WORLD);
            m_needUpdateView = true;
        }

        /// <summary>
        /// Rotate the camera relative to the world for the Up axis and local for Strafe and Heading.
        /// </summary>
        /// <param name="orient">Rotation.</param>
        public void Rotate(Vector3 orient)
        {
            if (AttachedToNode)
                return;
            m_node.Rotate(orient.Y, 0, 0, CNode.ESpace.WORLD);
            m_node.Rotate(0, orient.X, orient.Z, CNode.ESpace.LOCAL);
            m_needUpdateView = true;
        }

    #endregion

    }
}
